#ifndef CERTINFOWINDOW_H
#define CERTINFOWINDOW_H

#include <QFrame>
#include <QVBoxLayout>
#include <QMap>

class QLabel;

namespace Ui {
class CertInfoWindow;
}

typedef struct x509_st X509;

class CertInfoWindow : public QFrame
{
  Q_OBJECT

public:
  explicit CertInfoWindow(QWidget *parent = nullptr);
  ~CertInfoWindow();

  void ShowCert(X509* cert);

private:
  // page index: 0,1
  void AddInfoItem(const QString& label,
                   const QVariant& info,
                   int page_index);

  //
  QWidget* GetInfoItem(const QString& label,
                       const QVariant& info,
                       QWidget* parent);

  virtual void closeEvent(QCloseEvent *event);

private:
  Ui::CertInfoWindow *ui;
  X509* cert_ = nullptr;
  QMap<QString, QLabel*> basic_cert_labels_;
  QMap<QString, QLabel*> extend_cert_labels_;
};

#endif // CERTINFOWINDOW_H
